Page({
  data: {
    latitude: 0,
    longitude: 0,
    scale: 14,
    markers: [],
    polyline: [],
  },
  onLoad: function () {
    this.getLocation();
  },
  getLocation: function() {
    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        this.setData({
          latitude: res.latitude,
          longitude: res.longitude,
          markers: [{
            id: 1,
            latitude: res.latitude,
            longitude: res.longitude,
            iconPath: '/images/location.png',
            width: 20,
            height: 20
          }]
        });
      }
    });
  },
  markerTap: function(e) {
    // 点击标记点时触发事件
    console.log('markerTap', e);
    this.navigateTo()
  },

  navigateTo: function() {
    wx.openLocation({
      latitude: 26.64702,  // 目的地纬度
      longitude: 106.63024,  // 目的地经度
      scale: 14,
      name: '南明区',
      address: '花果园D区菜鸟驿站'
    });
  },

  regionChange: function(e) {
    // 地图视野发生变化时触发事件
    console.log('regionChange', e);
  }
});